package com.bw.liveplay.common.mvvm.adapter

import android.widget.ImageView
import android.widget.TextView
import com.bw.liveplay.R
import com.bw.liveplay.common.entity.FeedEntity
import com.bw.liveplay.common.network.LoadImage
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author KK
 * @description:
 * @date :2021/11/12 8:16
 *
 */
class ImgAdapter : BaseQuickAdapter<FeedEntity, BaseViewHolder>(R.layout.item_img) {
    override fun convert(holder: BaseViewHolder, item: FeedEntity) {
        var head = holder.getView<ImageView>(R.id.item_img_head)
        var text = holder.getView<TextView>(R.id.item_text)
        var name = holder.getView<TextView>(R.id.item_img_name)
        var imgview = holder.getView<ImageView>(R.id.item_img_img)

        var avatar = item.author!!.avatar
        if (avatar != null) {
            LoadImage.loadcrile(avatar,head)
        }//设置头像

        text.setText(item.author!!.name)//名称
        name.setText(item.feeds_text)//作者编辑的话
        var cover = item.cover
        if (cover != null) {
            LoadImage.loadMathImg(cover,imgview)
        }


    }
}